import React from "./react"
import ReactDOM from "./react-dom";

// function Home() {
//     return (<div className='active' title='123' >
//         hello,
//         <span onClick={() => { console.log(1); }}>
//             React
//             <h1>222
//                 <p>3123</p>
//             </h1>
//         </span>
//     </div>)
// }

class Home2 extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            num:0
        }
    }
    componentWillReveiveProps(props) {
        console.log(props,'props');
    }
    componmentWillMount() {
        console.log('组件将要加载');
    }
    componentDidMount() {
        console.log('组件加载完成');
    }
    componentWillUpdate() {
        console.log('组件将要更新');
    }
    componentDidUpdate() {
        console.log('组件更新');
    }
    handleCLick() {
       this.setState(this.state.num++)
    }
    render() {
        return (
            <div className='active' title='123' >
                hello,
                <span onClick={() => { console.log(1); }}>
                    React
                    <h1>222
                    <p>3123</p>
                    </h1>
                </span>
                <button onClick = {this.handleCLick.bind(this)}>点我</button>
                {this.state.num}
            </div>
        )
    }
}

console.time('a')
ReactDOM.render( <Home2 name='test'/>, document.querySelector('#root'))
console.timeEnd('a')